
class Person {
  String data;
  int age;
  String name;

  Person(data, {this.age, this.name}) {
    this.age = age;
    this.name = name;
    print('person');
    print('person $age');
    print('person $name');
  }

  void sayhi() {
    print('my name is' + this.name);
  }
}

class Worker extends Person {
  int salary;
  Worker(int age, String name, int salary) : super('xxx', age: age, name: name) { //super表示要继承父类的属性
    this.salary = salary;
    print('Worker');
    print('Worker $age');
    print('Worker $name');
    print(salary);
  }

  @override //告诉编译器和程序员他是一个重写覆盖父类的方法
  void sayhi() {
    super.sayhi(); //表示调用父类的sayhi方法
    print('my salary is $salary');
  }
}


runWorker () {
  var worker = Worker(1, 'xx', 2);
  worker.sayhi();

}
